package com.javacommunity.model.entity;

// Generated Nov 25, 2014 11:55:44 PM by Hibernate Tools 3.4.0.CR1

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "user_post", catalog = "db_javadanang", uniqueConstraints = @UniqueConstraint(columnNames = {
    "userId", "postId"}))
public class UserPost implements java.io.Serializable {

    private Integer userPostId;
    private User user;
    private Post post;
    private boolean vote;

    public UserPost() {
    }

    public UserPost(User user, Post post, boolean vote) {
        this.user = user;
        this.post = post;
        this.vote = vote;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "user_postId", unique = true, nullable = false)
    public Integer getUserPostId() {
        return this.userPostId;
    }

    public void setUserPostId(Integer userPostId) {
        this.userPostId = userPostId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "userId", nullable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "postId", nullable = false)
    public Post getPost() {
        return this.post;
    }

    public void setPost(Post post) {
        this.post = post;
    }

    @Column(name = "vote", nullable = false)
    public boolean isVote() {
        return this.vote;
    }

    public void setVote(boolean vote) {
        this.vote = vote;
    }

}
